using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace WindowsPhoneEssentials.Converters
{
    public class InverseBooleanToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is bool))
            {
                throw new NotSupportedException("InverseBooleanToVisibilityConverter should only be used on bool values.");
            }
            if ((bool)value)
            {
                return Visibility.Collapsed;
            }
            return Visibility.Visible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value.Equals(Visibility.Visible);
        }
    }
}